package secondModule.view {
	import flash.events.MouseEvent;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlexMediator;	
	
	public class SecondModuleMediator extends FlexMediator 
	{
		public static const NAME : String = "SecondModuleMediator"; 

		public function SecondModuleMediator(viewComponent : SecondModule) 
		{
			super(NAME, viewComponent);
		}
		
		override public function onRegister() : void
		{
			app.module2Button.addEventListener(MouseEvent.CLICK, handleButton1Click);
			app.moduleButton.addEventListener(MouseEvent.CLICK, handleButton2Click);
		}
		
		private function handleButton1Click(e:MouseEvent):void
		{
			routeNotification("messageToModule", null);
		}
		
		private function handleButton2Click(e:MouseEvent):void
		{
			routeNotification("messageToShell", null);
		}
		
		public function respondToSecondButtonClicked(note : INotification) : void
		{
			app.msgFromShell.text = "Message From Shell";
		}
		
		public function respondToMessageToModule(note:INotification):void
		{
			app.msgFromModule.text = "Message From Module";
		}
		
		private function get app() : SecondModule
		{
			return viewComponent as SecondModule;
		}
	}
}